package com.ruoyi.web.controller.shopType;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.shopType.domain.ShopType;
import com.ruoyi.shopType.service.IShopTypeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 商品类型管理Controller
 * 
 * @author zyn
 * @date 2025-05-24
 */
@RestController
@RequestMapping("/shopType/shopType")
public class ShopTypeController extends BaseController
{
    @Autowired
    private IShopTypeService shopTypeService;

    /**
     * 查询商品类型管理列表
     */
    @PreAuthorize("@ss.hasPermi('shopType:shopType:list')")
    @GetMapping("/list")
    public TableDataInfo list(ShopType shopType)
    {
        startPage();
        List<ShopType> list = shopTypeService.selectShopTypeList(shopType);
        return getDataTable(list);
    }

    /**
     * 导出商品类型管理列表
     */
    @PreAuthorize("@ss.hasPermi('shopType:shopType:export')")
    @Log(title = "商品类型管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ShopType shopType)
    {
        List<ShopType> list = shopTypeService.selectShopTypeList(shopType);
        ExcelUtil<ShopType> util = new ExcelUtil<ShopType>(ShopType.class);
        util.exportExcel(response, list, "商品类型管理数据");
    }

    /**
     * 获取商品类型管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('shopType:shopType:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(shopTypeService.selectShopTypeById(id));
    }

    /**
     * 新增商品类型管理
     */
    @PreAuthorize("@ss.hasPermi('shopType:shopType:add')")
    @Log(title = "商品类型管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ShopType shopType)
    {
        return toAjax(shopTypeService.insertShopType(shopType));
    }

    /**
     * 修改商品类型管理
     */
    @PreAuthorize("@ss.hasPermi('shopType:shopType:edit')")
    @Log(title = "商品类型管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ShopType shopType)
    {
        return toAjax(shopTypeService.updateShopType(shopType));
    }

    /**
     * 删除商品类型管理
     */
    @PreAuthorize("@ss.hasPermi('shopType:shopType:remove')")
    @Log(title = "商品类型管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(shopTypeService.deleteShopTypeByIds(ids));
    }
}
